package com.Arsanesia.TempleRush.Views.Screens;

import com.Arsanesia.TempleRush.TempleRush;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;

public class SplashScreen extends AbstractScreen{

	private Texture splashTexture;
	
	public SplashScreen(TempleRush game){
		super(game);
	}
	@Override
	public void show(){
		super.show();
		atlas = new TextureAtlas("Images/Splash/splash.atlas");

        // let's make sure the stage is clear
		this.clear();
        // here we create the splash image actor and set its size
        Image splashImage = new Image( new TextureRegionDrawable(atlas.createSprite("splashscreen")));

        // this is needed for the fade-in effect to work correctly; we're just
        // making the image completely transparent
        Color splashColor = splashImage.getColor(); 
        splashImage.setColor(splashColor.r, splashColor.g, splashColor.b, 0f);

        // configure the fade-in/out effect on the splash image
        SequenceAction sequenceactions = Actions.sequence(Actions.fadeIn(0.75f), Actions.delay(1.75f, Actions.fadeOut( 1.75f))
        		, new Action(){

					@Override
					public boolean act(float delta) {
							game.setScreen(game.getStoryScreen());
						return true;
					}
        			
        	
        		});
        
        splashImage.addAction(sequenceactions);

        // and finally we add the actors to the stage, on the correct order
        this.addActor( splashImage );
		
	}
	@Override
    public void resize(
        int width,
        int height )
    {
        super.resize( width, height );
    }
	 
    @Override
    public void dispose()
    {
        super.dispose();
        splashTexture.dispose();
    }
}
